<div class="app-content-body ">
    <div class="bg-light lter b-b wrapper-md hidden-print">
      <h1 class="m-n font-thin h3">项目详情</h1>
    </div>

    <div class="form_title">
      <div class="my_hd edit-type">
      	  <div class="tabs-title">
			<ul>
				<li class="on">项目信息</li>
				<li>项目进度</li>
				<li>项目分配</li>
				<li data-status>项目收益与评价</li>
			</ul>
      	  </div>
      </div>
      <div class="crud-container crud-reset">
        <form id="form-container">
          <div class="row">
            <div class="col-sm-12">
	            <div class="project-details">
	              	<div class="project-info">
	              	 	<div id="basic-info"></div>
	              	 	<div id="revised-info"></div>
	              	</div>
	              	<div class="project-process">
	              	 	<div id="milepost"></div>
	              	 	<div id="process"></div>
	              	</div>
	              	<div class="project-distribution"></div>
	              	<div class="project-profit-evaluate"></div>
              	</div>
            </div>
          </div>          
          <div class="row">
            <div class="col-sm-12 text-right" style="margin-top: 15px;">
                <div id="cancel"></div>
            </div>
          </div>
        </form>
      </div>
    </div>
</div>
<script type="text/javascript">
$(function (){
    $("#content").one("route.loaded", function(e, context) {
      	var id=context.params.id ,
      	  	memberStore = API('project/'+ id), //基本信息
      	  	milepost = API('project-milestone'), //里程碑
      	  	process = API('project-progress'), //进度
      	  	revised = API('project-revision'),  //修订信息
      	  	distribution = API('project-user');  //项目分配
      	
      	//---------------------基本信息start------------------------
      	var formItems = [{
	  		itemType: "group",
	  		caption: "基本信息",
	  		colCount: 2,
	  		items:[{
		        dataField: "title",
		        label: {text: '项目名称'}, 
		    },{
		        dataField: "user.username",
		        label: {text: '需求发布方'},
		    },{
		        dataField: "project_user.user.username",
		        label: {text: '项目执行方'},
		    },{
		      	dataField:"",
		      	editorType:"dxTextArea",
		      	label: {text:'说明'}
		    }]
      	}]
	    $.get(memberStore).then(function(msg){
	    	if(msg.data.status=='done'){
	    		$('.tabs-title li[data-status]').show();
	    	}
	    	console.log(msg.data.status)
	    	
		   	$("#basic-info").dxForm({
		   	  	formData:msg.data,
			    showColonAfterLabel: true,
			    showValidationSummary: false,
			    readOnly: true,
			    validationGroup: "crud",
			    items: formItems
		    }).dxForm("instance");
	  	},'json');
	  	
	  	$("#revised-info").dxDataGrid({
	        dataSource: $.crudStore(API('project-revision'), {
        		onLoading: function(loadOptions) {
	    			loadOptions.filter = ['project_id', '=', id];
	    		}
	    	}),
	        columns: [{
		        dataField: "created_at",
		        caption: '修订日期'
		    },{
		        dataField: "user.username",
		        caption: '修订人'
		    },{
		        dataField: "content",
		        caption: '修订内容'
		    }]
	    });
	    $('#revised-info').prepend("<div class='underline'>修订信息</div>");
	    
	    //---------------------------项目进度start-----------------------------------
	    $("#milepost").dxDataGrid({
	        dataSource: $.crudStore(API('project-milestone'), {
        		onLoading: function(loadOptions) {
	    			loadOptions.filter = ['project_id', '=', id];
	    		}
	    	}),
	        columns: [{
		        dataField: "created_at",
		        caption: '时间'
		    },{
		        dataField: "user.username",
		        caption: '名称'
		    }]
	    });
	    $('#milepost').prepend("<div class='underline'>里程碑</div>");
	    
	    $("#process").dxDataGrid({
	        dataSource: $.crudStore(API('project-progress'), {
        		onLoading: function(loadOptions) {
	    			loadOptions.filter = ['project_id', '=', id];
	    		}
	    	}),
	        columns: [{
		        dataField: "created_at",
		        caption: '时间'
		    },{
		        dataField: "project_milestone.title",
		        caption: '里程碑'
		    },{
		        dataField: "content",
		        caption: '内容'
		    }]
	    });
	    $('#process').prepend("<div class='underline'>进度</div>");
	    
	    //---------------------------项目分配start-----------------------------------
	    $(".project-distribution").dxDataGrid({
	        dataSource: $.crudStore(API('project-user'), {
        		onLoading: function(loadOptions) {
	    			loadOptions.filter = ['project_id', '=', id];
	    		}
	    	}),
	        columns: [{
		        dataField: "user.username",
		        caption: '会员名称'
		    },{
		        dataField: "user.mobile",
		        caption: '手机号'
		    },{
		        dataField: "format_type",
		        caption: '状态'
		    }]
	    });
	    $('.project-distribution').prepend("<div class='underline'>项目分配</div>");
	    
	    //---------------------------项目收益与评价start-----------------------------------
	    $(".project-profit-evaluate").dxDataGrid({
	        dataSource: memberStore,
	        columns: [{
		        dataField: "publish_rank",
		        caption: '需求发布方'
		    },{
		        dataField: "execute_rank",
		        caption: '项目执行方'
		    }]
	    });
	    $('.project-profit-evaluate').prepend("<div class='underline'>项目收益与评价</div>");
	    setTimeout(function(){
	    	$.get(memberStore).then(function(resp){
		    	resp = resp.data.project_user.income ;
		    	$('.project-profit-evaluate').append("<div class='evaluate'>项目执行方获得收益是：<i>"+resp+"</i></div>");
		    })
	    },1000)
			
	    $("#cancel").dxButton({
	          text: "返回",
	          type: "normal",
	          onClick:function() {
	          context.redirect("#/project-list");
	        }
	    });
	    function tabs(tabTit,on,tabCon){
	        $(tabTit).children().click(function(){
	            $(this).addClass(on).siblings().removeClass(on);
	            var index = $(tabTit).children().index(this);
	           	$(tabCon).children().eq(index).show().siblings().hide();
	    	});
		};
    	tabs(".tabs-title ul","on",".project-details");
    });
});
</script>